<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Class: LokiIndexedAdapter</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Class: LokiIndexedAdapter</h1>

    




<section>

<header>
    
        <h2><span class="attribs"><span class="type-signature"></span></span>LokiIndexedAdapter<span class="signature">(appname)</span><span class="type-signature"></span></h2>
        
    
</header>

<article>
    <div class="container-overview">
    
        

    

    
    <h4 class="name" id="LokiIndexedAdapter"><span class="type-signature"></span>new LokiIndexedAdapter<span class="signature">(appname)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Loki persistence adapter class for indexedDb.
    This class fulfills abstract adapter interface which can be applied to other storage methods. 
    Utilizes the included LokiCatalog app/key/value database for actual database persistence.
    Indexeddb is highly async, but this adapter has been made 'console-friendly' as well.
    Anywhere a callback is omitted, it should return results (if applicable) to console.
    IndexedDb storage is provided per-domain, so we implement app/key/value database to 
    allow separate contexts for separate apps within a domain.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>appname</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>(Optional) Application name context can be used to distinguish subdomains, 'loki' by default</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="loki-indexed-adapter.js.html">loki-indexed-adapter.js</a>, <a href="loki-indexed-adapter.js.html#line25">line 25</a>
    </li></ul></dd>
    

    

    

    
</dl>

















    <h5>Example</h5>
    
    <pre class="prettyprint"><code>var idbAdapter = new LokiIndexedAdapter('finance');</code></pre>



    
    </div>

    

    

    

    

    

    

    

    
        <h3 class="subsection-title">Methods</h3>

        
            

    

    
    <h4 class="name" id="checkAvailability"><span class="type-signature"></span>checkAvailability<span class="signature">()</span><span class="type-signature"> &rarr; {boolean}</span></h4>
    

    



<div class="description">
    <p>Used to check if adapter is available</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="loki-indexed-adapter.js.html">loki-indexed-adapter.js</a>, <a href="loki-indexed-adapter.js.html#line64">line 64</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>true if indexeddb is available, false if not.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">boolean</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="deleteDatabase"><span class="type-signature"></span>deleteDatabase<span class="signature">(dbname, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Deletes a serialized db from the catalog.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>dbname</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"><p>the name of the database to delete from the catalog.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>callback</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>(Optional) executed on database delete</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="loki-indexed-adapter.js.html">loki-indexed-adapter.js</a>, <a href="loki-indexed-adapter.js.html#line184">line 184</a>
    </li></ul></dd>
    

    

    

    
</dl>

















    <h5>Example</h5>
    
    <pre class="prettyprint"><code>// DELETE DATABASE// delete 'finance'/'test' value from catalogidbAdapter.deleteDatabase('test', function {  // database deleted});</code></pre>



        
            

    

    
    <h4 class="name" id="deleteDatabasePartitions"><span class="type-signature"></span>deleteDatabasePartitions<span class="signature">(dbname)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Removes all database partitions and pages with the base filename passed in.
This utility method does not (yet) guarantee async deletions will be completed before returning</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>dbname</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>the base filename which container, partitions, or pages are derived</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="loki-indexed-adapter.js.html">loki-indexed-adapter.js</a>, <a href="loki-indexed-adapter.js.html#line222">line 222</a>
    </li></ul></dd>
    

    

    

    
</dl>


















        
            

    

    
    <h4 class="name" id="getCatalogSummary"><span class="type-signature"></span>getCatalogSummary<span class="signature">(callback)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Allows retrieval of list of all keys in catalog along with size</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>callback</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            

            

            <td class="description last"><p>(Optional) callback to accept result array.</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="loki-indexed-adapter.js.html">loki-indexed-adapter.js</a>, <a href="loki-indexed-adapter.js.html#line292">line 292</a>
    </li></ul></dd>
    

    

    

    
</dl>


















        
            

    

    
    <h4 class="name" id="getDatabaseList"><span class="type-signature"></span>getDatabaseList<span class="signature">(callback)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Retrieves object array of catalog entries for current app.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>callback</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            

            

            <td class="description last"><p>should accept array of database names in the catalog for current app.</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="loki-indexed-adapter.js.html">loki-indexed-adapter.js</a>, <a href="loki-indexed-adapter.js.html#line247">line 247</a>
    </li></ul></dd>
    

    

    

    
</dl>

















    <h5>Example</h5>
    
    <pre class="prettyprint"><code>idbAdapter.getDatabaseList(function(result) {  // result is array of string names for that appcontext ('finance')  result.forEach(function(str) {    console.log(str);  });});</code></pre>



        
            

    

    
    <h4 class="name" id="loadDatabase"><span class="type-signature"></span>loadDatabase<span class="signature">(dbname, callback)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Retrieves a serialized db string from the catalog.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>dbname</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>the name of the database to retrieve.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>callback</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            

            

            <td class="description last"><p>callback should accept string param containing serialized db string.</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="loki-indexed-adapter.js.html">loki-indexed-adapter.js</a>, <a href="loki-indexed-adapter.js.html#line86">line 86</a>
    </li></ul></dd>
    

    

    

    
</dl>

















    <h5>Example</h5>
    
    <pre class="prettyprint"><code>// LOADvar idbAdapter = new LokiIndexedAdapter('finance');var db = new loki('test', { adapter: idbAdapter });  db.loadDatabase(function(result) {  console.log('done');});</code></pre>



        
            

    

    
    <h4 class="name" id="saveDatabase"><span class="type-signature"></span>saveDatabase<span class="signature">(dbname, dbstring, callback)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Saves a serialized db to the catalog.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>dbname</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>the name to give the serialized database within the catalog.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>dbstring</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>the serialized db string to save.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>callback</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            

            

            <td class="description last"><p>(Optional) callback passed obj.success with true or false</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="loki-indexed-adapter.js.html">loki-indexed-adapter.js</a>, <a href="loki-indexed-adapter.js.html#line137">line 137</a>
    </li></ul></dd>
    

    

    

    
</dl>

















    <h5>Example</h5>
    
    <pre class="prettyprint"><code>// SAVE : will save App/Key/Val as 'finance'/'test'/{serializedDb}var idbAdapter = new LokiIndexedAdapter('finance');var db = new loki('test', { adapter: idbAdapter });var coll = db.addCollection('testColl');coll.insert({test: 'val'});db.saveDatabase();  // could pass callback if needed for async complete</code></pre>



        
    

    

    
</article>

</section>




</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Collection.html">Collection</a></li><li><a href="DynamicView.html">DynamicView</a></li><li><a href="Loki.html">Loki</a></li><li><a href="LokiEventEmitter.html">LokiEventEmitter</a></li><li><a href="LokiFsAdapter.html">LokiFsAdapter</a></li><li><a href="LokiFsStructuredAdapter.html">LokiFsStructuredAdapter</a></li><li><a href="LokiIndexedAdapter.html">LokiIndexedAdapter</a></li><li><a href="LokiLocalStorageAdapter.html">LokiLocalStorageAdapter</a></li><li><a href="LokiMemoryAdapter.html">LokiMemoryAdapter</a></li><li><a href="LokiPartitioningAdapter.html">LokiPartitioningAdapter</a></li><li><a href="Resultset.html">Resultset</a></li></ul><h3>Tutorials</h3><ul><li><a href="tutorial-Autoupdating Collections.html">Autoupdating Collections</a></li><li><a href="tutorial-Changes API.html">Changes API</a></li><li><a href="tutorial-Collection Transforms.html">Collection Transforms</a></li><li><a href="tutorial-Indexing and Query performance.html">Indexing and Query performance</a></li><li><a href="tutorial-Loki Angular.html">Loki Angular</a></li><li><a href="tutorial-Persistence Adapters.html">Persistence Adapters</a></li><li><a href="tutorial-Query Examples.html">Query Examples</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu May 10 2018 03:42:33 GMT-0400 (Eastern Daylight Time)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>